import React from 'react';

export const classifyTypeOptions = [
  {
    selectLabel: '选择车辆',
    listType: 'mcd_car',
    label: '车辆',
    value: 6,
    title: '车牌号',
    pkIdKey: 'carNumber',
    nameKey: 'carNumber',
  },
  {
    selectLabel: '选择人员',
    listType: 'user',
    label: '个人',
    value: 5,
    title: '姓名',
    pkIdKey: 'userOID',
    nameKey: 'fullName'
  },
  {
    selectLabel: '选择公司',
    label: '公司',
    listType: 'auto_audit_add_company',
    value: 4,
    pkIdKey: 'companyOID',
    title: '公司',
    listExtraParams: {
      isCostCenter: 1,
    },
    nameKey: 'name'
  },
  {
    selectLabel: '选择人员组',
    listType: 'user_group',
    label: '人员组',
    value: 3,
    pkIdKey: 'userGroupOID',
    title: '人员组',
    nameKey: 'name'
  },
  {
    selectLabel: '选择部门',
    listType: 'mcd_department',
    label: '部门',
    pkIdKey: 'costCenterItemOID',
    value: 2,
    title: '部门',
    nameKey: 'name'
  },
  {
    selectLabel: '选择级别',
    label: '级别',
    pkIdKey: 'customEnumerationItemOID',
    listType: 'personTypeModel',
    value: 1,
    title: '级别',
    listExtraParams: {
      systemCustomEnumerationType: '1008'
    },
    nameKey: 'code'
  }
];

const cycleOptions = [
  {
    label: '年',
    value: 1,
  },
  {
    label: '月',
    value: 2
  },
  {
    label: '天',
    value: 3
  },
  {
    label: '季度',
    value: 4
  }
];

export function getClassifyType(classifyType) {
  const option = classifyTypeOptions.find((item) => item.value === classifyType);
  return option || {
    selectLabel: '-',
    listType: '-',
    label: '-',
    value: -1,
    title: '-',
    pkIdKey: '-',
    nameKey: '-',
  };
}

export function getClassifyTypeLabel(classifyType) {
  const option = classifyTypeOptions.find((item) => item.value === classifyType);
  if (!option) return '-';
  return option.label;
}

export function getCycleLabel(cycle) {
  const option = cycleOptions.find((item) => item.value === cycle);
  if (!option) return '-';
  return option.label;
}

export function getClassifyTypeSearchItem() {
  return {
    type: 'select',
    options: classifyTypeOptions,
    labelKey: 'label',
    valueKey: 'value',
    id: 'classifyType',
    label: '分类'
  };
}

export function getCycleSearchItem() {
  return {
    type: 'select',
    options: cycleOptions,
    labelKey: 'label',
    valueKey: 'value',
    id: 'cycle',
    label: '周期'
  };
}
